
$(document).ready(function() {
    
	$(".btnSendCode").click(function() {
		var realName = $("#realName").val();
		var zhifubao = $.trim($("#zhifubao").val());
		
		var nameReg = /^[\u2E80-\u9FFF]{2,5}$/;
		if(typeof(realName)!="undefined" && !nameReg.test(realName)) {
			Utils.msgDialog("请输入合法的支付宝实名！");
			return;
		}
		if(zhifubao.length < 7) {
			Utils.msgDialog("请输入合法的支付宝账号！");
			return;
		}
		
		var param = {
			captchaType: 1,
			captchaWay: 0,
			captchaUse: 604,
		};
		AQ.callAQ("applyCaptcha.do", param, function(result) {
			countDown($(".btnSendCode")[0], 60);
			$("#realName").prop("readOnly", true);
			$("#zhifubao").prop("readOnly", true);
		}, function(err, code){
			Utils.msgDialog(err + "["+ code +"]");
		});	
    });
	
	$("#bp-submit").click(function() {
		var realName = $.trim($("#realName").val());
		var zhifubao = $.trim($("#zhifubao").val());
		var code = $.trim($("#bp-code").val());
		
		var codeReg = /^[0-9]{6}$/;
		if(!codeReg.test(code)) {
			Utils.msgDialog("×  验证码格式不正确！");
			return false;
		}
		
        var param = {
			realName: realName,
			zhifubao: zhifubao,
			captchaCode: code,
		};
		AQ.callAQ("bindPay.do", param, function(result) {
			Utils.msgDialog("操作成功！");
			location.replace("user-center.html");
		}, function(err, code){
			Utils.msgDialog(err + "["+ code +"]");
		});
    });
	
});